$(function () {
    window.onload = function () {
        // 最新请求
        $.ajax({
            url: 'http://localhost:3000/play/new',
            type: 'get',
            success: function (pla) {
                console.log(pla);
                var plarr = '';
                $.each(pla, function (i, item) {
                    $.each(pla[i], function (index, dom) {
                        plarr += '<li>' + '<img class = "img1" src =' + dom.img + '><p> ' + dom.text + '</p><span class="price">' + dom.price + '</span><span class = "simg"><img src = "../img/small/reply.png"> 3 </span><span class = "simg"><img src = "../img/small/zan.png">3</span></li >'
                    })

                })
                $('.ku-play-ul').append(plarr);
            }
        });
        // 最热请求
        $.ajax({
            url: 'http://localhost:3000/play/hot',
            type: 'get',
            success: function (pla) {
                // console.log(pla.splice(2));
                var hot_ = pla.splice(2)
                var plarr = '';
                $.each(hot_, function (i) {
                    $.each(hot_[i], function (index, dom) {
                        plarr += '<li>' + '<img class = "img1" src =' + dom.img + '><p> ' + dom.text + '</p><span class="price">' + dom.price + '</span><span class = "simg"><img src = "../img/small/reply.png"> 3 </span><span class = "simg"><img src = "../img/small/zan.png">3</span></li >'
                    })
                })
                $('.ku-play-ul-1').append(plarr);
            }
        });
        // 品类部分
        // 1.生活
        $.ajax({
            url: 'http://localhost:3000/play/category',
            type: 'get',
            success: function (pla) {
                var plive = pla.splice(0, 1);
                console.log(plive);
                var plarr = '';
                // 生活
                $.each(plive, function (index, dom) {
                    // console.log(dom.list);
                    var lName = dom.list
                    $.each(lName, function (i, doEle) {
                        // console.log(doEle);
                        plarr += '<div class="list"><a href = ""><p class = "info">' + doEle.productName + '(' + doEle.nums + ')</p></a></div>'
                    })

                })
                $('.liveName').append(plarr);
                // 个护
                var person = pla.slice(1, 2);
                var huli = '';
                $.each(person, function (index, dom) {
                    console.log(dom.list);
                    var lName = dom.list
                    $.each(lName, function (i, doEle) {
                        // console.log(doEle);
                        huli += '<div class="list"><a href = ""><p class = "info">' + doEle.productName + '(' + doEle.nums + ')</p></a></div>'
                    })

                })
                $('.liveyiqi').append(huli);
                // 健康
                var phealth = pla.slice(2, 3);
                var hk = '';
                $.each(phealth, function (index, dom) {
                    console.log(dom.list);
                    var lName = dom.list
                    $.each(lName, function (i, doEle) {
                        // console.log(doEle);
                        hk += '<div class="list"><a href = ""><p class = "info">' + doEle.productName + '(' + doEle.nums + ')</p></a></div>'
                    })

                })
                $('.health').append(hk);
            }
        });
    }
    // 点击更多的时候
    $('.more').on({
        click: function () {
            $('.ku-content,.ku-content1').css('overflow', 'visible');
            $(this).remove('.more');
        },
    });
    $('.znew,.more,.tnew').on({
        mouseover: function () {
            $(this).addClass('cursor');
        },
        mouseout: function () {
            $(this).removeClass("cursor");
        }
    })
    // 更换页面
    $('.znew').on('click', function () {
        $(this).addClass('zre').siblings().removeClass('zre');
        var index = $(this).index();
        console.log(index);
        $('section').eq(index).show().siblings('section').hide();
    })
})